package beautifulWorld2D.engine 
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	/**
	 * ...
	 * @author Michel Pereira
	 */
	public class DecorElement extends MovieClip
	{
		
		private var _type:String;
		private var _inScreen:Boolean;
		
		protected var _xElement:int;
		protected var _yElement:int;
		
		protected var _xDecor:int;
		protected var _yDecor:int;
		protected var _scaleDecor:Number = 1;
		protected var _scaleThis:Number = 1;
		
		private var _animated:Boolean = false;
		
		public function DecorElement() 
		{
			_inScreen 	= false;
			_type 		= name;
			
			_scaleThis = super.scaleX;
			_xDecor = super.x;
			_yDecor = super.y;
			
			_xElement = super.x;
			_yElement = super.y;
			
			cacheAsBitmap = true;
			
			//addEventListener(Event.ADDED_TO_STAGE, onAddedStage);
			//addEventListener(Event.REMOVED_FROM_STAGE, onRemoveStage);
		}
		

		
		/*private function onAddedStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedStage);
			
			_screenRect.width = stage.stageWidth;
			_screenRect.height = stage.stageHeight;
			stage.addChild(_screenRect);
			stage.addEventListener(Event.ENTER_FRAME, enterFrame);
			

		}
		private function onRemoveStage(e:Event):void 
		{
			removeEventListener(Event.REMOVED_FROM_STAGE, onRemoveStage);
			stage.removeEventListener(Event.ENTER_FRAME, enterFrame);
		}
		private function enterFrame(e:Event):void 
		{
			if ( hitTestObject(_screenRect)) {
				_inScreen = true;
			}else {
				_inScreen = false;
			}
		}*/
		
		
		public function get type():String { return _type; }
		
		public function set type(value:String):void 
		{
			_type = value;
		}
		
		public function get inScreen():Boolean { return _inScreen; }
		
		public function set inScreen(value:Boolean):void 
		{
			if ( value != _inScreen) {
				_inScreen = value;
				
				if ( _inScreen) {
					enable();
				}else {
					disable();
				}
			}

		}
		
		public function dispose():void
		{

		}
		
		public function enable():void
		{

		}
		public function disable():void
		{

		}
		public function get zone():DisplayObject 
		{
			return this;

		}
		
		override public function get x():Number { return _xElement; }
		
		override public function set x(value:Number):void 
		{
			_xElement = value;
			xStage = _xDecor + _xElement*scaleDecor;
		}
		override public function get y():Number { return _yElement; }
		
		override public function set y(value:Number):void 
		{
			_yElement = value;
			yStage = _yDecor + _yElement*scaleDecor;
		}
		
		public function get xDecor():int { return _xDecor; }
		
		public function set xDecor(value:int):void 
		{
			_xDecor = value;
			xStage = _xDecor + _xElement*scaleDecor;
		}
		
		public function get yDecor():int { return _yDecor; }
		
		public function set yDecor(value:int):void 
		{
			_yDecor = value;
			yStage = _yDecor + _yElement*scaleDecor;
		}
		
		
		public function get xStage():int { return super.x; }
		
		public function set xStage(value:int):void 
		{
			super.x = value;
		}
		
		public function get yStage():int { return super.y; }
		
		public function set yStage(value:int):void 
		{
			super.y = value;
		}
		
		public function get animated():Boolean { return _animated; }
		
		public function set animated(value:Boolean):void 
		{
			_animated = value;
			if ( _animated) {
				cacheAsBitmap = false;
			}else {
				cacheAsBitmap = true;
			}
		}
		
		public function get scaleDecor():Number { return _scaleDecor; }
		
		public function set scaleDecor(value:Number):void 
		{
			_scaleDecor = value;
			super.scaleX = super.scaleY = _scaleDecor * _scaleThis;
		}

	}

}